package com.bootdo.sell.controller;

import com.bootdo.client.domain.ClientDO;
import com.bootdo.client.service.ClientService;
import com.bootdo.common.utils.PageUtils;
import com.bootdo.common.utils.Query;
import com.bootdo.goods.domain.GoodsDO;
import com.bootdo.goods.service.GoodsService;
import com.bootdo.settingDemo.domain.EmployeeinfoDO;
import com.bootdo.settingDemo.domain.SettleaccountDO;
import com.bootdo.settingDemo.service.EmployeeinfoService;
import com.bootdo.settingDemo.service.SettleaccountService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/get/table")
public class GetTable {

    @Autowired
    private GoodsService goodsService;
    @Autowired
    private ClientService clientService;
    @Autowired
    private SettleaccountService settleaccountService;
    @Autowired
    private EmployeeinfoService employeeinfoService;


    @ResponseBody
    @GetMapping("/list")
    public PageUtils list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);
        List<GoodsDO> goodsList = goodsService.list(query);
        int total = goodsService.count(query);
        PageUtils pageUtils = new PageUtils(goodsList, total);
        return pageUtils;
    }
    @GetMapping("/table")
    public String table(){return "sell/combo/gettable";}
    @GetMapping("/gtable")
    public String gtable(){return "sell/order/getgoodstable";}
    @ResponseBody
    @GetMapping("/clist")
    public PageUtils clist(@RequestParam Map<String, Object> params){
        Query query = new Query(params);
        List<ClientDO> clientDOList = clientService.list(query);
        int total = clientService.count(query);
        PageUtils pageUtils = new PageUtils(clientDOList, total);
        return pageUtils;
    }

    @GetMapping("/ctable")
    public String ctable(){return "sell/order/getclienttable";}

    @ResponseBody
    @GetMapping("/blist")
    public PageUtils blist(@RequestParam Map<String, Object> params){
        Query query = new Query(params);
        List<SettleaccountDO> settleaccountDOS = settleaccountService.list(query);
        int total = settleaccountService.count(query);
        PageUtils pageUtils = new PageUtils(settleaccountDOS, total);
        return pageUtils;
    }
    @GetMapping("/btable")
    public String btable(){return "sell/order/gettypetable";}


    @ResponseBody
    @GetMapping("/elist")
    public PageUtils elist(@RequestParam Map<String, Object> params){
        Query query = new Query(params);
        List<EmployeeinfoDO> employeeinfoDOS = employeeinfoService.list(query);
        int total = employeeinfoService.count(query);
        PageUtils pageUtils = new PageUtils(employeeinfoDOS, total);
        return pageUtils;
    }
    @GetMapping("/etable")
    public String etable(){return "sell/order/getemployeetable";}

}
